package 面试.遍历算法.String类型题目;

public class 回文判断 {
    public static void main(String[] args) {
        String str="上海自来水来自海上";
        int num = 1;
        for (int i = 0; i < str.length()/2; i++) {
            if(str.charAt(i) != str.charAt(str.length()-1-i)){
                num = 0;
            }
        }
        if(num == 1){
            System.out.println("是回文");
        }else {
            System.out.println("不是回文");
        }
    }
}
